﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using FreeSwitch.EventSocket;
using FreeSwitch.EventSocket.CallHandling;
using FreeSwitch.EventSocket.Commands.CallManagement;

namespace Example
{
	public class Program
	{
		public static void Main(string[] argv)
		{
			LogManager.Assign(new ConsoleLogger());

			EventSocket socket = new EventSocket(new IPEndPoint(IPAddress.Loopback, 8021), "ClueCon");
			socket.Start();
			socket.SendCommand(new Originate("sofia/internal/u100045", "8334"));

			var components = from c in typeof (CallManager).Assembly.GetTypes()
			                 where c.GetCustomAttributes(typeof (Component), true).Length > 0
			                 select c;
			foreach (Type type in components)
			{
				foreach (Type @interface in type.GetInterfaces())
				{
					if (@interface.Assembly == type.Assembly)
					{
						//register interface here.
					}
				}
			}
			
			/*
			TestProxy proxy  = new TestProxy("ClueCon");
			proxy.Start(new IPEndPoint(IPAddress.Loopback, 8021), new IPEndPoint(IPAddress.Loopback, 8022));
			Thread.Sleep(5000);
			//EventChannel temp = new EventChannel(new IPEndPoint(IPAddress.Loopback, 8022));
			//temp.Start();
			//*/
			Console.ReadLine();
		}
	}
}
